package com.example.springboot.Servies.Impl;

import com.example.springboot.JaveBean.Dept;
import com.example.springboot.JaveBean.Result;
import com.example.springboot.JaveBean.User;
import com.example.springboot.Servies.DeptServies;
import com.example.springboot.dao.Deptdao;
import com.example.springboot.mapper.DeptMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @Auther:Liu
 * @Testname:addDeptSerivesImpl
 * @Date:2025/4/1 10:17
 */
@Service
public class DeptSerivesImpl implements DeptServies {
    @Autowired
    Deptdao deptdao;

    @Autowired
    DeptMapper deptMapper;

    @Override
    public String addDeptServies(String ask) {
        if (ask.equals("添加数据啦!")) {
            String s = deptdao.addDeptdao("开始添加数据!");
            return s;
        } else {
            return "业务访问层错误!";
        }
    }

    public List<Dept> selectAllServices() {
        return deptMapper.selectAllDao();
    }

    public Dept selectOneServices(Integer id1) {
        return deptMapper.selectOneDao(id1);
    }

    public void deleteOneServices(Integer id) {
        deptMapper.deleteOneDao(id);
    }


    public void insertOneServices(Dept dept) {
        dept.setCreateTime(LocalDateTime.now());
        dept.setUpdateTime(LocalDateTime.now());
        deptMapper.insertOneDao(dept);
    }

    public void updateOneServices(Dept dept){
        deptMapper.updateOneDao(dept);
    }


    public User loginServices(User user){
       return deptMapper.loginDao(user);
    }
}
